home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Burning & Media
/
GB-PVR 1.2.13
/
GBPVR10213.msi
/
Cabs.w1.cab
/
Header.ascx.cs402
< prev
next >
Wrap
Text File
|
2008-01-01
|
8KB
|
189 lines
using System;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Xml;
namespace gbweb
{
/// <summary>
/// Summary description for Header.
/// </summary>
public partial class Header : UserControl
{
public string ActiveTab;
private Settings guideParams;
protected void Page_Load(object sender, EventArgs e)
{
headerList.Items.Clear();
guideParams = Global.Settings;
logo.Src = logo.Src.Replace("images", Convert.ToString(Session["theme"]));
logo.Attributes.Add("title", Global.Settings.GetVersionToolTip());
header.Attributes.Add("class", ActiveTab);
headerList.Items.Add("<a href=\"Guide.aspx\"><span>TV Guide</span></a>");
headerList.Items.Add("<a href=\"Manage.aspx\"><span>Manage Recordings</span></a>");
headerList.Items.Add("<a href=\"Search.aspx\"><span>Episode Search</span></a>");
headerList.Items.Add("<a href=\"Library.aspx?path=Video\"><span>Video Library</span></a>");
headerList.Items.Add("<a href=\"Library.aspx?path=Music\"><span>Music Library</span></a>");
headerList.Items.Add("<a href=\"PhotoViewer.aspx\"><span>Photo Library</span></a>");
headerList.Items.Add("<a href=\"Logout.aspx\"><span>Logout</span></a>");
headerList.Items.Add("<a href=\"Admin.aspx\"><span>Config</span></a>");
headerList.Items.Add("<a href=\"Info.aspx\"><span>Statistics</span></a>");
headerList.Items[0].Attributes.Add("id", "nav-guide");
headerList.Items[1].Attributes.Add("id", "nav-manage");
headerList.Items[2].Attributes.Add("id", "nav-search");
headerList.Items[3].Attributes.Add("id", "nav-Videolibrary");
headerList.Items[4].Attributes.Add("id", "nav-Musiclibrary");
headerList.Items[5].Attributes.Add("id", "nav-Photolibrary");
headerList.Items[6].Attributes.Add("id", "nav-logout");
headerList.Items[7].Attributes.Add("id", "nav-admin");
headerList.Items[8].Attributes.Add("id", "nav-info");
headerList.Items[6].Attributes.Add("class", "farright");
headerList.Items[7].Attributes.Add("class", "farright");
headerList.Items[8].Attributes.Add("class", "farright");
if (!guideParams.showStats)
{
headerList.Items.RemoveAt(8);
}
//Guest users do not have access to the Admin console
if (!Convert.ToBoolean((string) Session["NotGuestUser"]))
{
headerList.Items.RemoveAt(7);
}
if (!guideParams.showPhotoLib)
{
headerList.Items.RemoveAt(5);
}
if (!guideParams.showMusicLib)
{
headerList.Items.RemoveAt(4);
}
if (!guideParams.showVideoLib)
{
headerList.Items.RemoveAt(3);
}
//Guest users do not have access to episode search
if (!guideParams.showSearch || (!Convert.ToBoolean((string)Session["NotGuestUser"])))
{
headerList.Items.RemoveAt(2);
}
if (!guideParams.showManage)
{
headerList.Items.RemoveAt(1);
}
if (!guideParams.showTVGuide)
{
headerList.Items.RemoveAt(0);
}
getTheme();
//The below code is what is necessary to use the plugins directory in support of EWA plugins.
//The tabs are created from this code behind by reading the subdirectories under the plugins dirctory.
//This provides the ability for users to add new tabs of functionality or overide current functionality
//such as replacing the standard guide with one of thier own.
//XmlDocument configPlugins;
//string id = "";
//string href = "";
//string displayname = "";
//string[] plugins = Directory.GetDirectories(Server.MapPath(Request.ApplicationPath + "/plugins/"));
//headerList.InnerHtml = "";
//Array.Sort(plugins);
//foreach (string plugin in plugins)
//{
// if (File.Exists(Path.Combine(plugin, "plugin_config.xml")))
// {
// configPlugins = new XmlDocument();
// configPlugins.Load(Path.Combine(plugin, "plugin_config.xml"));
// // Retrieve all categories from the xml.
// XmlNodeList categories = configPlugins.SelectNodes("plugin_config");
// foreach (XmlNode pluginNode in categories)
// {
// id = pluginNode.SelectSingleNode("//plugin_id").InnerText;
// href = pluginNode.SelectSingleNode("//plugin_href").InnerText;
// displayname = pluginNode.SelectSingleNode("//plugin_display_name").InnerText;
// headerList.InnerHtml += "<li id=\"" + id + "\"><a href=\"" + href + "\"><span>" + displayname + "</span></a></li>";
// }
// }
//}
//headerList.InnerHtml += "<li id=\"nav-logout\" class=\"farright\"><a href=\"Logout.aspx\"><span>Logout</span></a></li>";
//headerList.InnerHtml += "<li id=\"nav-admin\" class=\"farright\"><a href=\"Admin.aspx\"><span>Config</span></a></li>";
//headerList.InnerHtml += "<li id=\"nav-info\" class=\"farright\"><a href=\"Info.aspx\"><span>Statistics</span></a></li>";
}
protected void Page_PreRender(object sender, System.EventArgs e)
{
}
private void getTheme()
{
//Check to see if the theme has been set in session and that the set theme is using the table view
string theme = Convert.ToString(Session["theme"]);
if (theme != null && theme != "" && theme.Substring(0, 7) == "themes/")
{
return;
}
else
{
//Since the session theme variable was not set or is using the css view we need to read the value from the cookie
HttpCookie cookie = Request.Cookies["theme"];
if (cookie != null && cookie.Value.Length > 0)
{
theme = cookie.Value;
}
else
{
theme = "Default";
}
//Verify that that the theme in the cookie is available in the table based selections. If it is not found set the theme to Default.
if (File.Exists(HttpContext.Current.Server.MapPath("~/themes/") + theme + "/styles.css"))
{
Session["theme"] = "themes/" + theme;
}
else
{
Session["theme"] = "themes/Default";
}
return;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
}
}